﻿/*
 * @Autor: PK
 * @Date: 2022/01/15 09:22:SS
 */

using System;
using System.Collections.Generic;
using O2DESNet.Distributions;
using ShkSimulation.core.template.agency;
using ShkSimulation.core.template.customer;

namespace ShkSimulation.carsharing.demo {

	public class DemoTemplate: CustomerTemplate {

		private readonly List<Agency> agencies;
		private Random random = new Random();
		
		public TimeSpan GenerateSpan { get; set; }
		
		public string UniqueKey { get; }

		public DemoTemplate(string uniqueKey, List<Agency> agencies, TimeSpan generateSpan) {
			this.UniqueKey = uniqueKey;
			this.agencies = agencies;
			this.GenerateSpan = generateSpan;
		}

		public Customer CreateCustomer() {
			return new DemoTraveler(new List<Agency>(agencies));
		}

		public DateTime GetCreateTimeAndPassNext(DateTime clockTime) {
			TimeSpan span = Exponential.Sample(random, GenerateSpan);
			return clockTime + span;
		}

		public List<Agency> GetCustomerAgencies() {
			return agencies;
		}

	}

}